'''
Created on 2009-6-9

@author: steven
'''

def buildConnectString(parameter):
    """
        Build a string from a dictionary from parameter return .
        Parameter should be the dictionary type
    """
    return ";".join(["%s=%s"%(k,v) for k,v in parameter.items()])
def testListAndDic():
    """Test the Python List and Dictionary"""
    tList = ["First","which",12,33,"hi"]
    tDict = {"name":"steven","Gendle":"Male","age":30}
    
    print tDict.keys(),"\n", \
          tDict.values(),"\n", \
          tDict.items()
    
    print "The List length: ",tList.__len__(), \
          "The dict length: ",tDict.__len__(), \
          
    tList.append("new one")
    tList.insert(2, "king")
    
    tList.remove("hi")
#Tuple : fixed List in Python
#can not be changed if creted
    tup = ("qwe","water","my","box")
        
    nt = tup[1:3]
    
    #print nt,"\n"
    #print "my" in nt
    print [elem*2 for elem in tList]
    
        
    for tl in tList:
        print tl
        
    for k,v in tDict.items():
        print "key:%s,value:%s\n"%(k,v)
            

if __name__=="__main__":
    myPara = {"server":"rx7640", \
              "database":"master", \
              "uid":"sa", \
              "pwd":"root" \
              }
    #print buildConnectString(myPara)
    testListAndDic()
    
    print range(10).__str__()+range.__doc__
    print "This is %d, and what is %s"%(12,"sample")
    conn = "$".join(["1=2","water","we"])
    print conn.split("$",1)
    
